import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function getUser(params) {
  return request({
    url: '/user/list',
    method: 'get',
    params
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

export function addUser(data) {
  return request({
    url: '/user/add',
    method: 'post',
    data
  })
}

export function getGoodsList(params) {
  return request({
    url: '/goods/list',
    method: 'get',
    params
  })
}

export function getCatesList(params) {
  return request({
    url: '/goods/cates',
    method: 'get',
    params
  })
}

export function removeGoods(params) {
  return request({
    url: '/goods/del',
    method: 'get',
    params
  })
}

export function editGoods(data) {
  return request({
    url: '/goods/add',
    method: 'post',
    data
  })
}

export function userExist (params) {
  return request({
    url: '/user/exist',
    method: 'get',
    params
  })
}

export default {
  login,
  getGoodsList,
  getCatesList,
  removeGoods,
  editGoods,
  getUser,
  addUser,
  userExist
}
